home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / 80x0393.zip / MOUSETUT.FAQ < prev    next >
Text File  |  1993-06-20  |  23KB  |  734 lines

  1.  
  2.                   The Microsoft Mouse Interface Tutorial
  3.                 By Matthew Hildebrand (FidoNet 1:247/128.2)
  4.                         Revision:  January 14, 1993
  5.  
  6.  
  7. Applications wishing to interface to the mouse should do so via calls to
  8. the industry-standard Microsoft or compatible mouse driver.  All calls to
  9. the driver are made through interrupt 33h.
  10.  
  11. A list of answers to frequently asked questions is at the end of this
  12. document.
  13.  
  14. Following is a summary of the functions the mouse driver provides.
  15.  
  16.  
  17.  
  18.  
  19.                      **** MOUSE DRIVER FUNCTIONS ****
  20.  
  21. ==============================
  22. Function 00h:  Reset mouse
  23.  
  24. Call with      AX = 0000h
  25.  
  26. Return         If mouse available
  27.                  AX = FFFFh
  28.                  BX = number of buttons
  29.                If mouse unavailable
  30.                  AX = 0000h
  31.  
  32. Notes          Calling this function will initialize the mouse hardware,
  33.                position the pointer at the screen center, set the pointer
  34.                display page to zero, hide the pointer, reset the pointer
  35.                shape to the default, disable any user-defined event
  36.                handlers, enable light pen emulation, set the horizontal
  37.                mickeys:pixels ratio to 8:8 and the vertical ratio to 16:8,
  38.                set the double speed threshold to 64 mickeys/second, and set
  39.                both the horizontal and vertical maximum and minimum pointer
  40.                bounds to include the entire screen.
  41.  
  42. See also       Function 21h
  43.  
  44.  
  45. ==============================
  46. Function 01h:  Show pointer
  47.  
  48. Call with      AX = 0001h
  49.  
  50. Return         Nothing
  51.  
  52. Notes          Calls to Functions 01h and 02h are cumulative; ie., if
  53.                Function 01h is called twice, Function 02h must be called
  54.                twice before the pointer becomes visible again.
  55. See also       Function 02h
  56.  
  57.  
  58. ==============================
  59. Function 02h:  Hide pointer
  60.  
  61. Call with      AX = 0002h
  62.  
  63. Return         Nothing
  64.  
  65. Notes          Calls to Functions 01h and 02h are cumulative; ie., if
  66.                Function 01h is called twice, Function 02h must be called
  67.                twice before the pointer becomes visible again.
  68.  
  69. See also       Function 01h
  70.  
  71.  
  72. ==============================
  73. Function 03h:  Get pointer position and button status
  74.  
  75. Call with      AX = 0002h
  76.  
  77. Return         BX = button status
  78.                  bit 0   left button down (if set)
  79.                  bit 1   right button down (if set)
  80.                  bit 2   center button down (if set)
  81.                CX = x coordinate
  82.                DX = y coordinate
  83.  
  84. Notes          Coordinates are always in pixels, where (0,0) is the upper-
  85.                left of the screen.
  86.  
  87. See also       Functions 04h-06h
  88.  
  89.  
  90. ==============================
  91. Function 04h:  Set pointer position
  92.  
  93. Call with      AX = 0004h
  94.                CX = x coordinate
  95.                DX = y coordinate
  96.  
  97. Return         Nothing
  98.  
  99. Notes          The new position will be disregarded if it lies within an
  100.                exclusion area.
  101.  
  102.                Coordinates are always in pixels, where (0,0) is the upper-
  103.                left of the screen.
  104.  
  105.                The position will be modified, if necessary, such that it
  106.                lies within the horizontal and vertical limits.
  107.  
  108. See also       Function 03h
  109.  
  110.  
  111. ==============================
  112. Function 05h:  Get button press information
  113.  
  114. Call with      AX = 0005h
  115.                BX = button
  116.                  0 = left button
  117.                  1 = right button
  118.                  2 = center button
  119.  
  120. Return         AX = button status
  121.                  bit 0   left button down (if set)
  122.                  bit 1   right button down (if set)
  123.                  bit 2   center button down (if set)
  124.                BX = button press counter (number since last call)
  125.                CX = x coordinate of last press
  126.                DX = y coordinate of last press
  127.  
  128. Notes          The button press counter for the specified button is reset
  129.                to zero following a call to this function.
  130.  
  131. See also       Function 05h
  132.  
  133.  
  134. ==============================
  135. Function 06h:  Get button release information
  136.  
  137. Call with      AX = 0006h
  138.                BX = button
  139.                  0 = left button
  140.                  1 = right button
  141.                  2 = center button
  142.  
  143. Return         AX = button status
  144.                  bit 0   left button down (if set)
  145.                  bit 1   right button down (if set)
  146.                  bit 2   center button down (if set)
  147.                BX = button release counter (number since last call)
  148.                CX = x coordinate of last release
  149.                DX = y coordinate of last release
  150.  
  151. Notes          The button release counter for the specified button is reset
  152.                to zero following a call to this function.
  153.  
  154. See also       Function 04h
  155.  
  156.  
  157. ==============================
  158. Function 07h:  Set pointer horizontal limits
  159.  
  160. Call with      AX = 0007h
  161.                CX = minimum x coordinate
  162.                DX = maximum x coordinate
  163.  
  164. Return         Nothing
  165.  
  166. Notes          The two values will be swapped if necessary.
  167.  
  168.                If necessary, the pointer will be moved such that it lies
  169.                within the new limits.
  170.  
  171. See also       Functions 08h, 10h
  172.  
  173.  
  174. ==============================
  175. Function 08h:  Set pointer vertical limits
  176.  
  177. Call with      AX = 0008h
  178.                CX = minimum y coordinate
  179.                DX = maximum y coordinate
  180.  
  181. Return         Nothing
  182.  
  183. Notes          The two values will be swapped if necessary.
  184.  
  185.                If necessary, the pointer will be moved such that it lies
  186.                within the new limits.
  187.  
  188. See also       Functions 07h, 10h
  189.  
  190.  
  191. ==============================
  192. Function 09h:  Set graphics pointer shape
  193.  
  194. Call with      AX = 0009h
  195.                BX = hot spot offset from left
  196.                CX = hot spot offset from top
  197.                ES:DX = segment:offset of image buffer
  198.  
  199. Return         Nothing
  200.  
  201. Notes          The hot spot is the pixel of the image which the driver
  202.                considers to be the current position.  For instance, an
  203.                arrow pointer would have its hot spot at the upper left,
  204.                while a crosshairs pointer would have it at the center. 
  205.                Both the horizontal and vertical offsets must be between -16
  206.                and 16 inclusive.
  207.  
  208.                The image buffer's length is 64 bytes.  The first 32 consist
  209.                of a bitmask which is ANDed with the screen image, and the
  210.                second 32 consist of a bitmap which is XORed with the screen
  211.                image.
  212.  
  213. See also       Function 0Ah
  214.  
  215.  
  216. ==============================
  217. Function 0Ah:  Set text pointer type
  218.  
  219. Call with      AX = 000Ah
  220.                BX = pointer type
  221.                  0 = software cursor
  222.                  1 = hardware cursor
  223.                CX = If BX=0:  AND mask
  224.                     If BX=1:  Starting scan line
  225.                DX = If BX=0:  XOR mask
  226.                     If BX=1:  Ending scan line
  227.  
  228. Return         Nothing
  229.  
  230. Notes          If a software cursor is selected, CX and DX are as follows:
  231.                     bits 0-7   character code
  232.                     bits 8-10  foreground colour
  233.                     bit 11     intensity bit
  234.                     bits 12-14 background colour
  235.                     bit 15     blink bit
  236.  
  237.                If the hardware cursor is selected, CX and DX are the
  238.                starting and ending scan lines for the blinking cursor which
  239.                the video card generates, which will depend upon the video
  240.                card used.
  241.  
  242.  
  243. ==============================
  244. Function 0Bh:  Read motion counters
  245.  
  246. Call with      AX = 000Bh
  247.                
  248. Return         CX = net horizontal mickey count
  249.                DX = net vertical mickey count
  250.  
  251. Notes          This function will return the net mouse displacement since
  252.                the last call to this function.  The returned values are
  253.                measured in mickeys, where a negative value is upwards or to
  254.                the left and a positive value is downwards or to the right.
  255.  
  256. See also       Functions 03h, 0Fh
  257.  
  258.  
  259. ==============================
  260. Function 0Ch:  Set user-defined mouse event handler
  261.  
  262. Call with      AX = 000Ch
  263.                CX = event mask
  264.                  bit 0   mouse movement
  265.                  bit 1   left button pressed
  266.                  bit 2   left button released
  267.                  bit 3   right button pressed
  268.                  bit 4   right button released
  269.                  bit 5   center button pressed
  270.                  bit 6   center button released
  271.                ES:DX = segment:offset of event handler
  272.  
  273. Return         Nothing
  274.  
  275. Notes          On entrance to the handler:
  276.                  AX = mouse event mask (see Notes)
  277.                  BX = button states
  278.                    bit 0 left button down (if set)
  279.                    bit 1 right button down (if set)
  280.                    bit 2 center button down (if set)
  281.                  CX = x coordinate of pointer
  282.                  DX = y coordinate of pointer
  283.                  DI = raw horizontal mickey count
  284.                  SI = raw vertical mickey count
  285.                  DS = mouse driver data segment
  286.  
  287.                The event mask specified in CX is placed in AX before each
  288.                call to the handler, regardless of which of the events it
  289.                specifies actually occurred.
  290.  
  291.                The handler may be deactivated by calling function 00h or
  292.                this function with an event mask of zero.
  293.  
  294. See also       Functions 14h, 18h
  295.  
  296.  
  297. ==============================
  298. Function 0Dh:  Activate light pen emulation
  299.  
  300. Call with      AX = 000Dh
  301.  
  302. Return         Nothing
  303.  
  304. Notes          This function activates light pen emulation for IBM BASIC. 
  305.                The pen down condition is simulated by pressing the left and
  306.                right buttons simultaneously.
  307.  
  308. See also       Function 0Eh
  309.  
  310.  
  311. ==============================
  312. Function 0Eh:  Deactivate light pen emulation
  313.  
  314. Call with      AX = 000Eh
  315.  
  316. Return         Nothing
  317.  
  318. Notes          None.
  319.  
  320. See also       Function 0Dh
  321.  
  322.  
  323. ==============================
  324. Function 0Fh:  Set mickeys to pixels ratio
  325.  
  326. Call with      AX = 0Fh
  327.                CX = horizontal mickeys (default=8)
  328.                DX = vertical mickeys (default=16)
  329.  
  330. Return         Nothing
  331.  
  332. Notes          The mickey values must be between 1 and 32767 inclusive.
  333.  
  334.                This function will set the number of mickeys necessary for 8
  335.                pixels of motion to occur.
  336.  
  337. See also       Functions 13h, 1Ah, 1Bh
  338.  
  339.  
  340. ==============================
  341. Function 10h:  Set pointer exclusion area
  342.  
  343. Call with      AX = 0010h
  344.                CX = upper left x coordinate
  345.                DX = upper left y coordinate
  346.                SI = lower right x coordinate
  347.                DI = lower right y coordinate
  348.  
  349. Return         Nothing
  350.  
  351. Notes          This function defines an exclusion area wherein the pointer
  352.                is not displayed.  The exclusion area is cancelled by a call
  353.                to function 00h or 01h, or replaced by another call to this
  354.                function.
  355.  
  356. See also       Functions 00h-02h
  357.  
  358.  
  359. ==============================
  360. Function 13h:  Set double speed threshold
  361.  
  362. Call with      AX = 0013h
  363.                DX = speed in mickeys/second
  364.  
  365. Return         Nothing
  366.  
  367. Note           This function sets the minimum speed necessary before
  368.                pointer motion will double.  The default is 64
  369.                mickeys/second; doubling can be disabled by setting DX to a
  370.                large value.
  371.  
  372. See also       Functions 0Fh, 1Ah, 1Bh
  373.  
  374.  
  375. ==============================
  376. Function 14h:  Swap user-defined mouse event handlers
  377.  
  378. Call with      AX = 0014h
  379.                CX = event mask
  380.                  bit 0   mouse movement
  381.                  bit 1   left button pressed
  382.                  bit 2   left button released
  383.                  bit 3   right button pressed
  384.                  bit 4   right button released
  385.                  bit 5   center button pressed
  386.                  bit 6   center button released
  387.                ES:DX = segment:offset of event handler
  388.  
  389. Return         CX = previous event mask
  390.                ES:DX = segment:offset of previous event handler
  391.  
  392. Notes          On entrance to the handler:
  393.                  AX = mouse event flags (see Notes)
  394.                  BX = button states
  395.                    bit 0 left button down (if set)
  396.                    bit 1 right button down (if set)
  397.                    bit 2 center button down (if set)
  398.                  CX = x coordinate of pointer
  399.                  DX = y coordinate of pointer
  400.                  DI = raw horizontal mickey count
  401.                  SI = raw vertical mickey count
  402.                  DS = mouse driver data segment
  403.  
  404.                The handler may be deactivated by calling function 00h or
  405.                this function with an event mask of zero.
  406.  
  407. See also       Functions 0Ch, 18h
  408.  
  409.  
  410. ==============================
  411. Function 15h:  Get save state buffer size
  412.  
  413. Call with      AX = 0015h
  414.  
  415. Return         BX = buffer size in bytes
  416.  
  417. Notes          Before running any external programs, applications should
  418.                save the mouse driver state; doing so will ensure that any
  419.                event handlers, sensitivity settings, or other settings will
  420.                remain intact.  Of course, the driver state should be
  421.                restored when the external program is complete.
  422.  
  423. See also       Functions 16h, 17h
  424.  
  425.  
  426. ==============================
  427. Function 16h:  Save driver state
  428.  
  429. Call with      AX = 0016h
  430.                ES:DX = segment:offset of buffer
  431.  
  432. Return         Nothing
  433.  
  434. Note           Before running any external programs, applications should
  435.                save the mouse driver state; doing so will ensure that any
  436.                event handlers, sensitivity settings, or other settings will
  437.                remain intact.  Of course, the driver state should be
  438.                restored when the external program is complete.
  439.  
  440. See also       Functions 15h, 17h
  441.  
  442.  
  443. ==============================
  444. Function 17h:  Restore driver state
  445.  
  446. Call with      AX = 0017h
  447.                ES:DX = segment:offset of buffer
  448.  
  449. Return         Nothing
  450.  
  451. Note           Before running any external programs, applications should
  452.                save the mouse driver state; doing so will ensure that any
  453.                event handlers, sensitivity settings, or other settings will
  454.                remain intact.  Of course, the driver state should be
  455.                restored when the external program is complete.
  456.  
  457. See also       Functions 15h, 16h
  458.  
  459.  
  460. ==============================
  461. Function 18h:  Set alternate mouse event handler
  462.  
  463. Call with      AX = 0018h
  464.                CX = event mask
  465.                  bit 0   mouse movement
  466.                  bit 1   left button pressed
  467.                  bit 2   left button released
  468.                  bit 3   right button pressed
  469.                  bit 4   right button released
  470.                  bit 5   center button pressed
  471.                  bit 6   center button released
  472.                ES:DX = segment:offset of event handler
  473.  
  474. Return         If successful
  475.                  AX = 0018h
  476.                If unsuccessful
  477.                  AX = FFFFh
  478.  
  479. Notes          On entrance to the handler:
  480.                  AX = mouse event flags (see Notes)
  481.                  BX = button states
  482.                    bit 0 left button down (if set)
  483.                    bit 1 right button down (if set)
  484.                    bit 2 center button down (if set)
  485.                  CX = x coordinate of pointer
  486.                  DX = y coordinate of pointer
  487.                  DI = raw horizontal mickey count
  488.                  SI = raw vertical mickey count
  489.                  DS = mouse driver data segment
  490.  
  491.                The handler may be deactivated by calling function 00h.
  492.  
  493.                As many as three alternate event handlers, with unique event
  494.                masks, may be installed.
  495.  
  496. See also       Functions 0Ch, 14h
  497.  
  498.  
  499. ==============================
  500. Function 19h:  Get address of alternate mouse event handler
  501.  
  502. Call with      AX = 0019h
  503.                CX = event mask
  504.  
  505. Return         If successful
  506.                  CX = event mask
  507.                  ES:DX = segment:offset of alternate event handler
  508.                If unsuccessful
  509.                  CX = 0000h
  510.  
  511. Notes          None.
  512.  
  513. See also       Function 18h
  514.  
  515.  
  516. ==============================
  517. Function 1Ah:  Set sensitivity
  518.  
  519. Call with      AX = 001Ah
  520.                BX = horizontal mickeys (default=8)
  521.                CX = vertical mickeys (default=16)
  522.                DX = double speed threshold (default=64)
  523.  
  524. Return         Nothing
  525.  
  526. Notes          This function will set the number of mickeys necessary for 8
  527.                pixels of motion to occur, as well as the double speed
  528.                threshold.
  529.  
  530. See also       Functions 0Fh, 13h, 1Bh
  531.  
  532.  
  533. ==============================
  534. Function 1Bh:  Get mouse sensitivity
  535.  
  536. Call with      AX = 001Bh
  537.  
  538. Return         BX = horizontal mickeys
  539.                CX = vertical mickeys
  540.                DX = double speed threshold
  541.  
  542. Notes          None.
  543.  
  544. See also       Functions 0Fh, 13h, 1Ah
  545.  
  546.  
  547. ==============================
  548. Function 1Ch:  Set mouse interrupt rate
  549.  
  550. Call with      AX = 001Ch
  551.                BX = interrupt rate flags
  552.                  bit 0   no interrupts (if set)
  553.                  bit 1   30 interrupts/second (if set)
  554.                  bit 2   50 interrupts/second (if set)
  555.                  bit 3   100 interrupts/second (if set)
  556.                  bit 4   200 interrupts/second (if set)
  557.  
  558. Return         Nothing
  559.  
  560. Notes          This function will only affect InPort mice.
  561.  
  562. See also       Function 24h
  563.  
  564.  
  565. ==============================
  566. Function 1Dh:  Set pointer page
  567.  
  568. Call with      AX = 001Dh
  569.                BX = page
  570.  
  571. Return         Nothing
  572.  
  573. Notes          Valid page numbers depend on the active display mode.
  574.  
  575. See also       Function 1Eh
  576.  
  577.  
  578. ==============================
  579. Function 1Eh:  Get pointer page
  580.  
  581. Call with      AX = 001Eh
  582.  
  583. Return         BX = page
  584.  
  585. Notes          None.
  586.  
  587. See also       Function 1Dh
  588.  
  589.  
  590. ==============================
  591. Function 1Fh:  Disable mouse driver
  592.  
  593. Call with      AX = 001Fh
  594.  
  595. Return         If successful
  596.                  AX = 001Fh
  597.                  ES:BX = segment:offset of previous INT 33h handler
  598.                If unsuccessful
  599.                  AX = FFFFh
  600.  
  601. Notes          This function causes the mouse driver to release all
  602.                interrupts other than INT 33h.  The driver may then be
  603.                effectively removed by restoring the previous contents of
  604.                the INT 33h vector.
  605.  
  606. See also       Function 20h
  607.  
  608.  
  609. ==============================
  610. Function 20h:  Enable mouse driver
  611.  
  612. Call with      AX = 0020h
  613.  
  614. Return         Nothing
  615.  
  616. Notes          Calling this function will re-enable the mouse driver and
  617.                the servicing of mouse interrupts.
  618.  
  619. See also       Function 1Fh
  620.  
  621.  
  622. ==============================
  623. Function 21h:  Reset mouse driver
  624.  
  625. Call with      AX = 0021h
  626.  
  627. Return         If mouse support available
  628.                  AX = FFFFh
  629.                  BX = number of buttons
  630.                If mouse support unavailable
  631.                  AX = 0021h
  632.  
  633. Notes          The difference between this function and function 00h is
  634.                that this function performs no initialization of the mouse
  635.                hardware.
  636.  
  637. See also       Function 00h
  638.  
  639.  
  640. ==============================
  641. Function 22h:  Set language for driver messages
  642.  
  643. Call with      AX = 0022h
  644.                BX = language code
  645.                  0 = English
  646.                  1 = French
  647.                  2 = Dutch
  648.                  3 = German
  649.                  4 = Swedish
  650.                  5 = Finnish
  651.                  6 = Spanish
  652.                  7 = Portuguese
  653.                  8 = Italian
  654.  
  655. Return         Nothing
  656.  
  657. Notes          This function is available only with international versions
  658.                of the mouse driver.
  659.  
  660. See also       Function 23h
  661.  
  662.  
  663. ==============================
  664. Function 23h:  Get language
  665.  
  666. Call with      AX = 0023h
  667.  
  668. Return         BX = language code
  669.  
  670. Notes          This function is available only with international versions
  671.                of the mouse driver.
  672.  
  673. See also       Function 22h
  674.  
  675.  
  676. ==============================
  677. Function 24h:  Get mouse information
  678.  
  679. Call with      AX = 0024h
  680.  
  681. Return         BH = major version number of driver
  682.                BL = minor version number of driver
  683.                CH = mouse type
  684.                  1 = bus mouse
  685.                  2 = serial mouse
  686.                  3 = InPort mouse
  687.                  4 = PS/2 mouse
  688.                  5 = HP mouse
  689.                CL = IRQ number
  690.                  0 = PS/2
  691.                  2, 3, 4, 5, or 7 = IRQ number
  692.  
  693. Notes          None.
  694.  
  695. See also       None.
  696.  
  697.  
  698.  
  699.  
  700.                    **** FREQUENTLY ASKED QUESTIONS ****
  701.  
  702. Q:   When I write something to the screen, it overwrites the mouse pointer. 
  703.      Then, when I move the mouse, the pointer comes back, along with a
  704.      rectangle of outdated screen information.  What do I do?
  705. A:   The mouse driver keeps track of what was behind the pointer so that it
  706.      may be restored when the mouse is moved.  To avoid this problem, hide
  707.      the pointer before writing to the screen, then show it when you're
  708.      done.
  709.  
  710. Q:   When I'm in 320x200x256 mode or text mode, the driver returns
  711.      incorrect coordinate values.  What's wrong?
  712. A:   For whatever reason, the mouse driver returns values in this way when
  713.      in these modes.  In 320x200x256 mode, the driver uses horizontal
  714.      values which are actually twice the real value; shift the real value
  715.      left one bit when passing a coordinate to the driver, and shift the
  716.      returned value right one bit before using a value returned by the
  717.      driver.  Note that this shifting is only necessary for the horizontal
  718.      coordinate.  As for text mode, it's something of a similar absurd
  719.      nature, such as twice the real value in one direction and thrice in
  720.      the other, but I'm not sure.
  721.  
  722. Q:   What the hell's a mickey, anyway?
  723. A:   The mickey is the smallest amount of motion the mouse can detect.  One
  724.      mickey is 1/200" on a 200 DPI mouse, 1/400" on a 400 DPI mouse, etc..
  725.  
  726. Q:   How do I get those nifty-looking 256-colour mouse pointers?
  727. A:   You write a mouse event handler which will be called whenever the
  728.      mouse moves.  You may also wish to trap INT 33h for calls such as hide
  729.      pointer and show pointer.
  730.  
  731.  
  732.  
  733. End of document
  734.